import * as Type from './type'
import axios from 'axios'

const changeLogin = () => ({
  type: Type.LOGIN,
  value: true
})

export const loginout = () => ({
  type: Type.LOGINOUT,
  value: false
})

export const login = (account, password)=>{
  return (dispatch) => {
    axios.get('/api/login.json?account='+account+'&password='+password).then(res => {
      const result = res.data.data
      if(result){
        dispatch(changeLogin())
      }
    })
  }
}